package com.terrynoya.fight.stateMachine.controllers
{
	import com.terrynoya.fight.char.Character;
	import com.terrynoya.fight.emuns.MoveType;
	import com.terrynoya.fight.emuns.PhysicsEnum;
	import com.terrynoya.fight.emuns.StateTypeEnum;
	import com.terrynoya.fight.stateMachine.StateController;
	import com.terrynoya.fight.stateMachine.triggers.Physics;
	import com.terrynoya.fight.util.Misc;
	
	public class StateTypeSet extends StateController
	{
		private var _stateType:int;
		private var _moveType:int;
		private var _physics:int;
		
		public function StateTypeSet(name:String)
		{
			super(name);
		}
		
		override public function build():void
		{
			this._stateType = Misc.getStateType(this.getAttribute("statetype"));
			this._moveType = Misc.getMoveType(this.getAttribute("movetype"));
			this._physics = Misc.getPhysicsType(this.getAttribute("Physics"));	
		}
		
		override public function run(character:Character):void
		{
			if(this._stateType != StateTypeEnum.Unchanged && this._stateType != StateTypeEnum.NONE)
			{
				character.state = this._stateType;
			}
			if(this._moveType != MoveType.Unchanged && this._moveType != MoveType.None)
			{
				character.moveType = this._moveType;
			}
			if(this._physics != PhysicsEnum.Unchanged && this._moveType != PhysicsEnum.NONE)
			{
				character.physics = this._physics;
			}
		}
	}
}